<%@ page language="java" import="java.util.*,net.roseparadise.config.*" pageEncoding="UTF-8"%>

<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
	
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
	<head>

		<title>Rose Paradise</title>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<script type="text/javascript" src="<%=basePath%>/js/ext/ext-base.js"></script>
		<link rel="stylesheet" type="text/css"
			href="<%=basePath%>/css/ext-all.css" />
		<script type="text/javascript"
			src="<%=basePath%>/js/ext/ext-all-debug.js"></script>
		<script type="text/javascript"
			src="<%=basePath%>/js/locale/ext-lang-zh_CN.js"></script>
		<script type="text/javascript" src="<%=basePath%>ajax/engine.js"></script>
		<script type="text/javascript" src="<%=basePath%>ajax/util.js"></script>
		<script type="text/javascript" src="<%=basePath%>ajax/interface/LoginCheckAjax.js"></script>	
		<script type="text/javascript">
			function goMainHome(){
	  			document.forms.mainForm.action="<%=basePath%>action/MainHome.htm?cmd=show";
	            document.forms.mainForm.submit();
	  		}
	  		
	  		Ext.apply(Ext.form.VTypes, {		   
			    password : function(val, field) {
			        if (field.initialPassField) {
			            var pwd = Ext.getCmp(field.initialPassField);
			            return (val == pwd.getValue());
			        }
			        return true;
			    },			   
			    passwordText : Rose.Locale.Register.pwConfirmText
			});
			Ext.onReady(function(){
				Ext.QuickTips.init();
				// turn on validation errors beside the field globally
   				Ext.form.Field.prototype.msgTarget = 'side';
				
			    var form = new Ext.form.FormPanel({
			        renderTo:document.body,
			        title:Rose.Locale.Register.titleText,
			        url:'<%=basePath%>action/Login.htm?cmd=adduser',
			        defaultType: 'textfield',
			        width:600,
			       
			        frame:true,
			        items: [{
			            name: 'name',
			            fieldLabel: Rose.Locale.Register.nameText,
			            allowBlank:false,
			            vtype:'alphanum',
			            minLength : 2,
			            maxLength : 30,
			            msgTarget : 'side',
			            listeners :{
							valid : function(f,e) {
									LoginCheckAjax.checkNameUsed(f.getRawValue(),{callback:function(dataFromServer){	
										if("used"==dataFromServer){							
												f.markInvalid(Rose.Locale.Register.nameCheckText);
							       			}     
										} 
									});													         
							    }
							}
			        },{			            
			            name: 'password',
			            fieldLabel: Rose.Locale.Register.pwText,
			            inputType:'password',
			            allowBlank:false,
			            vtype:'alphanum',
			            minLength : 6,
			            maxLength : 12,
			            id:'password'
			        },{
			            name: 'passwordConfirm',
			            fieldLabel: Rose.Locale.Register.pwAgainText,
			            inputType:'password',			           
			            vtype:'password',
			            initialPassField: 'password'
			        },{
			            name: 'email',
			            fieldLabel: Rose.Locale.Register.emailText,			            
			            minLength : 6,
			            maxLength : 30,
			            vtype:'email'			           
			        },{
			            name: 'tel',
			            fieldLabel: Rose.Locale.Register.telText,
			            allowBlank:false,			            
			            minLength : 6,
			            maxLength : 12,
			            maskRe:/[0-9]/			           
			        },{
			            name: 'qq',
			            fieldLabel: Rose.Locale.Register.qqText,
			            minLength : 5,
			            maxLength : 15,
			            maskRe:/[0-9]/
			        },{
			            name: 'msn',
			            fieldLabel: Rose.Locale.Register.msnText,
			            minLength : 6,
			            maxLength : 30,
			            vtype:'email'			           
			        }],
			         buttons: [{
			            text: Rose.Locale.Register.sendText,
			            listeners: {
			            	click: function(){
			            		
			        			form.getForm().submit({
			        				success:function(f,a){
				        				if(a.result.success=="true"){
				        					goMainHome();
				        				}else{
				        					Ext.Msg.alert(Rose.Locale.Register.failureTitleText,Rose.Locale.Register.registerFailureText);
				        				}			        					
			        				},
			        				failure:function(f,a){
			        					Ext.Msg.alert(Rose.Locale.Register.failureTitleText,Rose.Locale.Register.failureText);
			        				}
			        			});
			                }
			            }
			        },{
			            text: Rose.Locale.Register.cancelText,
			            listeners: {
			            	click: function(){		                    
			                	form.getForm().reset();
			                }
			            }
			        }]
			    });
		});
	
	</script>
	</head>
	
	<body>
	<form name="mainForm" method="POST">
			<input type="hidden" name="isstudio" value="" />
			<input type="hidden" name="memberid" value="" />
	</form>
	</body>
</html>
